import zipfile

from .base_file import CommonFile


class ZIPFileUtils(CommonFile):

    @classmethod
    def get_zip_file(cls,filePath):
        """
        获取zip文件对象
        :param filePath:
        :return:
        """
        assert cls.get_file_ext_name(filePath) == "zip"
        return zipfile.ZipFile(filePath)

    @classmethod
    def get_name_list(cls, zipobj: zipfile.ZipFile):
        return zipobj.namelist()

    @classmethod
    def get_file_name(cls, zipobj: zipfile.ZipFile):
        return zipobj.filename

